package com.oa.modules.approvalsec1.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import com.oa.modules.sys.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.oa.common.utils.AppUtils;
import com.oa.common.utils.PageUtils;
import com.oa.common.utils.R;

import com.oa.modules.approvalsec1.entity.SuperviseHandleEntity;
import com.oa.modules.approvalsec1.service.SuperviseHandleService;




/**
 * 督办记录表
 *
 * @author jiangwei
 * @email 785297226@qq.com
 * @date 2021-03-29 11:01:03
 */
@RestController
@RequestMapping("supervise/handle")
@Api(tags = "督办记录表相关接口")
public class SuperviseHandleController extends AbstractController {
    @Autowired
    private SuperviseHandleService superviseHandleService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "列表")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = superviseHandleService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @ApiOperation(value = "信息")
    public R info(@PathVariable("id") String id){
		SuperviseHandleEntity superviseHandle = superviseHandleService.getById(id);
        return R.ok().put("superviseHandle", superviseHandle);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation(value = "保存")
    public R save(@RequestBody SuperviseHandleEntity superviseHandle){
        superviseHandle.setId(AppUtils.getUUID());
        superviseHandle.setCreateDate(new Date());
        superviseHandle.setCreateOper(getUserId().toString());
		superviseHandleService.save(superviseHandle);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation(value = "修改")
    public R update(@RequestBody SuperviseHandleEntity superviseHandle){
        superviseHandle.setUpdateDate(new Date());
        superviseHandle.setUpdateOper(getUserId().toString());
		superviseHandleService.updateById(superviseHandle);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    @ApiOperation(value = "删除")
    public R delete(@RequestBody String[] ids){
		superviseHandleService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
